var app = getApp();
var Util = require('../../utils/util.js')
var Json = require('../../json.js')
var is_submit = false;
Page({
  /**
   * 页面的初始数据
   */

  data: {
    parameter: {
      'title': '访客登记',
      'navbar': '1'
    },
    basicServe: []
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {

    this.app = getApp()

    let list = [{
        id: 1,
        memberNickname: '距结束',
        remainTime: 86400000
      },

    ];
    this.setData({
      listData: list
    });
    this.setCountDown();

    if (options.spid) app.globalData.spid = options.spid;
    if (options.scene) app.globalData.code = decodeURIComponent(options.scene);
    var that = this;
    wx.getSetting({
      success(res) {
        if (!res.authSetting['scope.userInfo']) {
          that.setData({
            window: true,
          });
        }
        // console.log(that.areas)
      }
    });



  },

  formSubmit: function(e) {

    // console.log(e.detail.value.userName); 
    if (is_submit) return;
    is_submit = true;
    /*if (e.detail.value.userName == '') {
      wx.showToast({
        title: '请输入姓名',
        duration: 1000,
        icon: 'loading',
      });
      is_submit = false;
      return;
    }
    if (e.detail.value.phone == '') {
      wx.showToast({
        title: '请输入手机号',
        duration: 1000,
        icon: 'loading',
      });
      is_submit = false;
      return;
    }*/
    wx.showLoading({
      title: '提交成功',
      duration: 4000,
      icon: 'success',
    });
    getCurrentPages().pop() 
    wx.redirectTo({
      url: '../visitors-audit/index',
    });


  


  },

  //上传
  chooseImage: function(e) {
    var index = e.currentTarget.dataset['index'];
    if (!index) {
      index = this.data.images.length;
    }
    var that = this;
    wx.chooseImage({
      count: 2,
      sizeType: ['original', 'compressed'],
      sourceType: ['album', 'camera'],
      success: res => {
        const image = res.tempFilePaths;
        var dimages = that.data.images;

        dimages[index] = image;
        dimages = dimages.length <= 2 ? dimages : dimages.slice(1, 3);
        that.setData({
          images: dimages
        })
      }
    })
  },

  catchTouchMove: function(res) {
    return false
  },
  onColse: function() {

  },
  onLoad: function() {

  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

    var that = this


  }
})